/*
*web114 项目商家公用脚本 caripower 2007.10.19
*1.分页
*2.String 扩展
*3.Array 扩展
*4.全选/反选
*5.判断checkbox 选中
*6.ajax请求
*/

/*----------------------------------------------------
*翻页开始
*/

//分页 CPage v3.1 author:laoding LastUpdate:2006-04-04
//=== 异步读取数据分页开始 ===
var CP_TitArr	=new Array();		//保存标志
var CP_CountArr	=new Array();		//保存总记录数
var CP_NPageArr	=new Array();		//保存当前页
var CP_UrlArr	=new Array();		//保存连接记录
var CP_FuncArr	=new Array();		//保存动作函数
var CP_FlagArr	=new Array();		//保存名称
var PageCounts=0;					//记录多个地方分页时的总计数
//document.createStyleSheet(ProjectPath + 'style/page.css');	//导入分页样式表
/*-----------------------------------------------------
*	分页 CPage v3.3 author:laoding creat:2005-12-22	LastUpdate:2006-06-28
*	@update 2006-6-28 新增分页样式 v3.2
*	@update 2006-8-4 修订分页输入框对页码的判断及点击分页的动作函数 v3.3 
*	显示异步读取的分页信息
*	@param PageShow	显示容器，同时和PageTitle一起组成本次分页的标志。如果不指定显示位置的话，分页信息将显示在该id标志的页面元素
*	@param howpages	一页显示多少条
*	@param Page_url	下一页的链接
*	@param PageFlag	本次分页的标志
*	@param TotalC	总计录数
*	@param func		指定的动作函数，即把Page_url和pageno传递给该函数
*	@param PageShowT	指定显示位置，这样，同一个分页可以显示在多个页面元素中
*	@param display	指定显示样式
					1、形如：首页 上一页 共2538/16页 下一页 末页 到 页GO
					2、形如：首页 上一页 2538/16  到 页GO 短
					3、形如：首页 上一页 共2538/16页 下一页 末页
					5、形如：上一页  下一页
					4、短型 形如：<< < 2538/16 > >>
					6、默认 页码 << < 3 4 5 6 7 8 9 10 11 12 13 > >> 
*	@nPageNoCount 当前显示几个页码 3 4 5 6 7 8 9 10 11 12 13 默认为10个
*	@Page_now 传入当前是哪个页
*	@return null
*/ 
function creatPage(PageShow,howpages,Page_url,PageFlag,TotalC,func,PageShowT,display,nPageNoCount,Page_now){
	if (nPageNoCount == null) nPageNoCount = 10;//在页面上最多显示几个页码
	var NCou=-1;	//判断是哪个地方的分页
	for(i=0;i<=PageCounts;i++){if(CP_TitArr[i]==PageFlag){NCou=i;}}
	//如果是第一次
	if(NCou==-1){
		//之前可能已经存在其他形式的分页
		if(CP_TitArr[PageCounts]!=null){PageCounts++;NCou=PageCounts;}else{NCou=PageCounts;}
		//初始化
		CP_TitArr[NCou]=PageFlag;	//记录分页标志
		CP_NPageArr[NCou]=1;		//记录本次分页的当前页	
		CP_FuncArr[NCou]=func;		//记录本次分页返回运行的函数
		CP_FlagArr[NCou]=PageShow;	//记录本次分页内容的显示位置
	}
	if (Page_now != null) CP_NPageArr[NCou] = Page_now;
	CP_UrlArr[NCou]=Page_url;	//记录本次分页的url
	if(TotalC==null||TotalC==""){
		//如果没有指定总记录数，那说明总记录数在生成的页面中
		CP_CountArr[NCou]=document.getElementById(PageShow+"Tb").count;
	}else{
		CP_CountArr[NCou]=TotalC;
	}
	
	//计算总页数
	var totalpage=CP_CountArr[NCou]%howpages==0?parseInt(CP_CountArr[NCou]/howpages):(parseInt(CP_CountArr[NCou]/howpages)+1);
	if(totalpage==0){
		document.getElementById(PageShow).innerHTML=""//"<font color=#eeeeee>无分页信息</font>";
	}else{
		if(display==null){display=5;}	//默认为分页样式1
		var pageStr="";	//定义向外输出的分页信息
		switch(display){
			case 1:	//分页样式1 形如：首页 上一页 共2538/16页 下一页 末页 到 页GO
				var firstpage=CP_NPageArr[NCou]==1?"<span class='page1_unlink'>首页</span>":"<span class='page1_link' onclick=\"turnPage("+ NCou +","+ totalpage +",1)\" id='"+ CP_FlagArr[NCou] +"_Home'>首页</span>";
				var downpage=CP_NPageArr[NCou]==totalpage?"<span class='page1_unlink'>下一页</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ (CP_NPageArr[NCou]*1+1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Down'>下一页</span>";
				var uppage=CP_NPageArr[NCou]==1?"<span class='page1_unlink'>上一页</span>":"<span onclick=\"turnPage("+NCou+","+ totalpage +","+ (CP_NPageArr[NCou]*1-1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Up'>上一页</span>";
				var endpage=CP_NPageArr[NCou]==totalpage?"<span class='page1_unlink'>末页</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ totalpage +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_End'>末页</span>";
				pageStr=firstpage+" "+uppage+" <span class='page1_unlink'>共"+CP_NPageArr[NCou]+"/"+totalpage+"页</span> "+downpage+" "+endpage+" <span class='page1_unlink'>到<input type='text' id='"+ CP_FlagArr[NCou] +"PN' class='page1_input' size='2' maxlength='4' onKeyDown=\"checkEnter('"+CP_FlagArr[NCou]+"GO')\">页</span><span id='"+ CP_FlagArr[NCou] +"GO' class='page1_btn' onclick=\"turnPage("+ NCou +","+ totalpage +")\">GO</span>";
			break;
			case 2:	//分页样式2 形如：首页 上一页 共2538/16页  到 页GO
				var firstpage=CP_NPageArr[NCou]==1?"":"<span class='page1_link' onclick=\"turnPage("+ NCou +","+ totalpage +",1)\" id='"+ CP_FlagArr[NCou] +"_Home'>首页</span>";
				var downpage=CP_NPageArr[NCou]==totalpage?"":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ (CP_NPageArr[NCou]*1+1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Down'>下一页</span>";
				var uppage=CP_NPageArr[NCou]==1?"":"<span onclick=\"turnPage("+NCou+","+ totalpage +","+ (CP_NPageArr[NCou]*1-1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Up'>上一页</span>";
				var endpage=CP_NPageArr[NCou]==totalpage?"":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ totalpage +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_End'>末页</span>";
				pageStr=firstpage+" "+uppage+" <span class='page1_unlink'>"+totalpage+"/"+CP_NPageArr[NCou]+"</span> "+downpage+" "+endpage+" <span class='page1_unlink'>到<input type='text' id='"+ CP_FlagArr[NCou] +"PN' class='page1_input' size='2' maxlength='4' onKeyDown=\"checkEnter('"+CP_FlagArr[NCou]+"GO')\">页</span><span id='"+ CP_FlagArr[NCou] +"GO' class='page1_btn' onclick=\"turnPage("+ NCou +","+ totalpage +")\">GO</span>";
			break;
			case 3:	//分页样式3 形如：首页 上一页 共2538/16页 下一页 末页 
				var firstpage=CP_NPageArr[NCou]==1?"<span class='page1_unlink'>首页</span>":"<span class='page1_link' onclick=\"turnPage("+ NCou +","+ totalpage +",1)\" id='"+ CP_FlagArr[NCou] +"_Home'>首页</span>";
				var downpage=CP_NPageArr[NCou]==totalpage?"<span class='page1_unlink'>下一页</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ (CP_NPageArr[NCou]*1+1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Down'>下一页</span>";
				var uppage=CP_NPageArr[NCou]==1?"<span class='page1_unlink'>上一页</span>":"<span onclick=\"turnPage("+NCou+","+ totalpage +","+ (CP_NPageArr[NCou]*1-1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Up'>上一页</span>";
				var endpage=CP_NPageArr[NCou]==totalpage?"<span class='page1_unlink'>末页</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ totalpage +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_End'>末页</span>";
				pageStr=firstpage+" "+uppage+" <span class='page1_unlink'>共"+totalpage+"/"+CP_NPageArr[NCou]+"页</span> "+downpage+" "+endpage;
			break;
			case 4:	//分页样式4 形如：上一页  下一页 
				var downpage=CP_NPageArr[NCou]==totalpage?"<span class='page1_unlink'>下一页</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ (CP_NPageArr[NCou]*1+1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Down'>下一页</span>";
				var uppage=CP_NPageArr[NCou]==1?"<span class='page1_unlink'>上一页</span>":"<span onclick=\"turnPage("+NCou+","+ totalpage +","+ (CP_NPageArr[NCou]*1-1) +")\" class='page1_link' id='"+CP_FlagArr[NCou]+"_Up'>上一页</span>";
				pageStr=uppage+"　"+downpage;
			break;
			case 5:	//分页样式5 形如：<< < 2538/16 > >> 
				var firstpage=CP_NPageArr[NCou]==1?"<span class='page2_btn'>|&lt;</span>":"<span class='page2_btn' onclick=\"turnPage("+ NCou +","+ totalpage +",1)\" id='"+ CP_FlagArr[NCou] +"_Home' title='到首页'>|&lt;</span>";
				var downpage=CP_NPageArr[NCou]==totalpage?"<span class='page2_btn'>&gt;</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ (CP_NPageArr[NCou]*1+1) +")\" class='page2_btn' id='"+CP_FlagArr[NCou]+"_Down'  title='下一页'>&gt;</span>";
				var uppage=CP_NPageArr[NCou]==1?"<span class='page2_btn'>&lt;</span>":"<span onclick=\"turnPage("+NCou+","+ totalpage +","+ (CP_NPageArr[NCou]*1-1) +")\" class='page2_btn' id='"+CP_FlagArr[NCou]+"_Up' title='上一页'>&lt;</span>";
				var endpage=CP_NPageArr[NCou]==totalpage?"<span class='page2_btn'>&gt;|</span>":"<span onclick=\"turnPage("+ NCou +","+ totalpage +","+ totalpage +")\" class='page2_btn' id='"+CP_FlagArr[NCou]+"_End' title='到末页'>&gt;|</span>";
				pageStr=firstpage+" "+uppage+" <span class='page2_text'>"+totalpage+"/"+CP_NPageArr[NCou]+"</span> "+downpage+" "+endpage;
			break;
			default://分页样式6 形如：页码 << < 3 4 5 6 7 8 9 10 11 12 13 > >> 
				var firstpage=CP_NPageArr[NCou]==1?"":"<span class='page2_blur' onclick=\"turnPage("+NCou+","+totalpage+",1)\" id='"+CP_FlagArr[NCou]+"_Home' title='到首页'><<</span>&nbsp;";
				var uppage=CP_NPageArr[NCou]==1?"":"<span class='page2_blur' onclick=\"turnPage("+NCou+","+totalpage+","+(CP_NPageArr[NCou]*1-1)+")\" id='"+CP_FlagArr[NCou]+"_Up' title='上一页'><</span>&nbsp;";
				var downpage=CP_NPageArr[NCou]==totalpage?"":"<span class='page2_blur' onclick=\"turnPage("+NCou+","+totalpage+","+(CP_NPageArr[NCou]*1+1)+")\" id='"+CP_FlagArr[NCou]+"_Down' title='下一页'>></span>&nbsp;";
				var endpage=CP_NPageArr[NCou]==totalpage?"":"<span class='page2_blur' onclick=\"turnPage("+NCou+","+totalpage+","+totalpage+")\" id='"+CP_FlagArr[NCou]+"_End' title='到最后一页'>>></span>";
				var pagelist="";	//显示页码
				var nStartPage=1;	//从第几页开始显示
				var nStartPage=CP_NPageArr[NCou]==1?1:(CP_NPageArr[NCou]-1);	//如果当前页不是第一页，默认从当前页的上一页开始显示
				if((nStartPage+nPageNoCount)>totalpage&&totalpage>=nPageNoCount){nStartPage=totalpage-nPageNoCount+1}	//如果当前页后面的页码总和小于nPageNoCount页，从倒数第nPageNoCount条开始显示
				if(totalpage<nPageNoCount){nStartPage=1;}		//如果页码总和小于nPageNoCount页，从第一页开始显示
				for(var j=nStartPage;(j<=totalpage)&&(j<(nStartPage+nPageNoCount));j++){
					if(j==CP_NPageArr[NCou]){
						pagelist+="<span class='page2_focus'>"+j+"</span> ";
					}else{
						pagelist+="<span class='page2_blur' onclick=\"turnPage("+NCou+","+totalpage+","+j+")\" onMouseOver=\"this.className='page2_focus';\" onMouseOut=\"this.className='page2_blur';\">"+j+"</span> ";
					}
				}
				pageStr="<span class='page2_text'>页码</span> "+firstpage+uppage+pagelist+downpage+endpage;
			break;
		}
		if(PageShowT!=null&&PageShowT!=""){PageShow=PageShowT}
		document.getElementById(PageShow).innerHTML=pageStr;
	}
}
function checkErr(object, msg, mobject) {
	try{
		var span = document.createElement("SPAN");
		var sstyle = span.style;
		span.id = "__ErrorMessagePanel";
		span.name = "__ErrorMessagePanel";
		sstyle.marginBottom = "2px";
		sstyle.padding = "3px";
		sstyle.lineHeight = "24px";
		sstyle.backgroundColor = "#F3FFF3";
		sstyle.border = "solid 1px #B0FFB0";
		sstyle.color = "red";
		if (mobject != null) {
			mobject.appendChild(span);
			setTimeout(function(){clearErr(mobject)}, 3000);
		} else {
			object.parentNode.appendChild(document.createElement("BR"));
			object.parentNode.appendChild(span);
		}
		span.innerHTML = "<b>" + msg.replace(/\d+:/,"*") + "<b>";
	}catch(e){}
}
function clearErr(mobject) {
	if (mobject != null) mobject.innerHTML = "";
	try {
		var allNode = getByName("__ErrorMessagePanel");
		if (allNode == null) return false;
		for(i = 0; i < allNode.length; i++) {
			var perentN = allNode[i].parentElement;
			var lastNode = perentN.lastChild;
			if(lastNode.id == "__ErrorMessagePanel")
				perentN.removeChild(lastNode);
				lastNode = perentN.lastChild;
			if(lastNode.nodeName == "BR")
				perentN.removeChild(lastNode);
		}
	} catch(e) {}
}
function checkEnter(obj){
	if(event.keyCode==13){document.getElementById(obj).fireEvent("onclick");return false;}	
}
/**
*	turnPage() 判定输入的页码是否正确并运行分页
*	@param nNcou	//当前分页在总分页数组中的下标
*	@param nTotalPage	//当前分页的总页码
*	@param nPageNo	//当前分页的页码,如果不指定，说明当前的页码从输入框中来
*/
function turnPage(nNcou,nTotalPage,nPageNo){
	var oTempObj=document.getElementById(CP_FlagArr[nNcou]+"PN");	//得到页码输入框
	if((nPageNo==""||nPageNo==null)&&oTempObj){nPageNo=oTempObj.value;}	//得到输入框内值
	var sWrongStr="";	//定义错误
	if(nPageNo==""){
		sWrongStr="请输入页码！";
	}else if(nPageNo.toString().match(/^(?:[1-9]\d*|0)$/) == null){
		sWrongStr="请在页码中输入数字！";
	}else if(nPageNo<=0||nPageNo>nTotalPage){
		sWrongStr="您输入的页码超出范围！";
	}
	if(sWrongStr!=""){
		alert(sWrongStr);
		oTempObj.focus();
		oTempObj.select();
		return false;
	}else{		
		CP_NPageArr[nNcou]=nPageNo;	//保存当前分页的当前页码
		eval(CP_FuncArr[nNcou]+"'"+CP_UrlArr[nNcou]+"','"+nPageNo+"','"+CP_TitArr[nNcou]+"');");
	}
}
/**-----------------------------------------------------
*翻页结束
*-----------------------------------------------------
*/
function oftenHtml(fString){
	if(fString=="")return("");
	
	fString = fString.replace(/&gt;/ig,">")	//>
	fString = fString.replace(/&lt;/ig,"<")	//<
	fString = fString.replace(/&quot;/ig,"\"")				//"
	fString = fString.replace(/&#39;/ig,"'")				//'
	fString = fString.replace(/&amp;/ig,"&") //&
	fString = fString.replace(/&nbsp;/ig," ")
	return fString;
}
//把过滤空格写成String的私有函数
String.prototype.ltrim = function(){
	return this.replace(/^\s+/g,"");
};
String.prototype.rtrim = function(){
	return this.replace(/\s+$/g,"");
};
String.prototype.trim = function(){
	return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.set = function(key, values) {
	return this.replace("?" + key + "?", values);
};
String.prototype.delnull = function(values) {
	return this.replace("null", "");
};
String.prototype.encode = function(){//字符串编码
	return encodeURI(this);
};
String.prototype.decode = function(){
	return decodeURI(this);
};
String.prototype.isSafe = function(){//扩展字符检测 删除了对 () 的过滤 /[-\!@#\$%\^&\*\.\[\]\(\)\{\}<>\?\\\/\'\"]/ by woo
    var re = /[-\!@#\$%\^&\*\.\[\]\{\}<>\?\\\/\'\"]/ 
	return (this.search(re) >= 0) ? false:true;
}
String.prototype.isChinese = function(){//扩展字符检测是否乱码
	var re = /^[a-z\~\ A-Z0-9\u0391-\uFFE5_]+$/;
	return (re.test(this)) ? true:false;
}
String.prototype.escapeUrl = function(){//转变URL二次参数
	return this.replace(/\&/g,"$$$");
}
String.prototype.unEscapeUrl = function(){//转变URL二次参数
	return this.replace(/\$\$/ig,"&");
}
String.prototype.hasHTMLCode = function(){
	if (this.indexOf("&")>-1 || this.indexOf("'")>-1 || this.indexOf("<")>-1 || this.indexOf(">")>-1 || this.indexOf("\"")>-1){
		return true;
	}else{
		return false;
	}		
}

String.prototype.delnull = function(flag){
	var arr = new Array();
	var newArr = new Array();
	arr = this.split(flag);
	for (i = 0;i < arr.length;i++ ) {
		if (arr[i] != null && arr[i].trim() != "") newArr.push(arr[i]);
	}
	return this.replace(this,newArr.join(flag));
}
/////Array 扩展
//数组方法扩展
//数组移除一个元素
Array.prototype.remove = function(value){
	var count = -1;
	for (i =0;i < this.length; i++)	{
		if (this[i] == value) count = i;
	}
	if (count < 0) return ;
	if(this.splice){return this.splice(count,1);}
	var tempArr=this.slice(count+1,this.length);
	for(var i=this.length-count;i>0;i--){
		this.pop();
	}
	for(var j=0;j<tempArr.length;j++){
		this.push(tempArr[j]);
	}
	return;
}; 
Array.prototype.isexist = function(value){
	value = value.trim();
	var flag = false;
	for(i = 0;i < this.length;i++){
		if (this[i].trim() == value){
			flag = true;
			return flag;
		}
	}
	return flag;
};
Array.prototype.del = function(index){
 	//var count = -1;
	count=index;
	if (index > this.length || count <0 ) return ;
	if(this.splice){return this.splice(index,1);}
	var tempArr=this.slice(index+1,this.length);
	for(var i=this.length-count;i>0;i--){
		this.pop();
	}
	for(var j=0;j<tempArr.length;j++){
		this.push(tempArr[j]);
	}
	return;
}; 
Array.prototype.trim = function(){
	for(i = 0;i < this.length;i++){
		if (typeof(this[i]) == "string") this[i] == this[i].trim();
	}
	return this;
}
//取得对象
function getById(id){
	return (document.getElementById(id)) ? document.getElementById(id):null;
}
function getByAll(name){
	var temp = document.all[name];
	return (temp != null) ? temp:null;
}
function getByName(name){
	return (document.getElementsByName(name)) ? document.getElementsByName(name):null;
}
//取地址栏各参数
function getUrlParam(as_param){
	var fs_url = window.location.href;
	var fi_index,fi_index1;
	fi_index = fs_url.indexOf("?");
	if (fi_index > -1){
		fs_url = "&" + fs_url.substring(fi_index+1);
		fi_index = fs_url.indexOf("&" + as_param + "=");
		if (fi_index > -1){
			fi_index1 = fs_url.indexOf("&",fi_index + 2);
			if (fi_index1 ==-1) fi_index1=9999;
			return fs_url.substring(fi_index + as_param.length + 2,fi_index1);
		}else{
			return "";
		}
	}else{
		return "";
	}
}
/**
 *param divName 要显示的容器
 *param type 类型，true 为显示,false 为隐藏
 */
function showDiv(divName,type){
	var div = document.getElementById(divName);
	if (div != null ){
		div.style.display = (type) ? "":"none";
	}
	return ;
}
/**
*	checkbox的全选及取消全选动作
*	@param isCheck 是选中(true)还是取消选中(false)
*	@param form checkbox所属的form
*	@param checkboxName 所有checkbox的统一名称
*/
function selectAllpoi(isCheck,form,checkboxName){	
	if(!form)return false;
	if(!form(checkboxName))return false;	
	if(form(checkboxName).length){
		for(i=0;i<form(checkboxName).length;i++){
			if(form(checkboxName)[i].checked!=isCheck){
				form(checkboxName)[i].parentElement.parentElement.fireEvent("onclick");
			};
		}
	}else{
		if(form(checkboxName).checked!=isCheck){
			form(checkboxName).parentElement.parentElement.fireEvent("onclick");
		};
	}
	return true;
}
/*2
//全选和反选
*/
function selectall(object){
	if (object == null){return;}
	if (object.length == null) {object.checked = true; return ;}
	for(i = 0;i < object.length; i++) {
		object[i].checked = true;
	}
	return ;
}
function unselectall(object){
	if (object == null){return;}
	if (object.length == null) {object.checked = false; return ;}
	for(i = 0;i < object.length; i++) {
		if (object[i].checked) {
			object[i].checked = false;
		}else{
			object[i].checked = true;
		}
	}
	return ;
}
function unDispDiv(object){
	var object = object.style;
	var stat = null;
	if (object.display != null) {
		stat = object.display == "none";
		object.display = (stat) ? "":"none";
		return !stat;
	}
}
//确认多少个被选中
function checkListSelect(object){		
	var checkCount=0;
	if(object==null){return false;}
	if(object.length){
		for(var i=0;i<object.length;i++){
			if(object[i].checked){
				checkCount++;
			}
		}
	}else{
		if(object.checked)checkCount=1;
	}
	//if(checkCount==0){alert("请选择要操作的记录！");return false;}
	return checkCount;
}

//生成一个ajax对象
function getRequest(){
	var req=null;
		try{
			req=new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				req=new ActiveXObject("Microsoft.XMLHTTP"); 
			}catch(e){
				req=null;
			};
		};
		if (req==null && typeof XMLHttpRequest!='undefined') {
  			req = new XMLHttpRequest();
		};
		return req;
};

//===================数据异步读取======================
var returnData;
/**
*	异步数据读取
*	注意该函数中当数据读取出现错误时，将运行函数Pf_RequestEnd()来释放查询锁定
*	@param xmlPath	数据源xml地址
*	@param xslPath	对该xml进行解析的xsl地址
*	@param func		函数，数据解析完毕后转向执行的函数，如果有指定Sid，该值无效
*	@param Sid		指定数据显示的位置
*	@param reValue	变量名称，解析完的数据赋值到该变量，如果有指定Sid，该值无效
*	@param format	是否格式化出来的数据，比如把数据中的'&gt;'替换成'>',false 不替换，true替换，默认为false状态
*/
var processorArr = new Array();
var xslDocArr = new Array();
var xmlDocArr = new Array();
function getXmlData(xmlPath,xslPath,func,Sid,reValue,format){
	var getDataFlag=getRandFlag();
	processorArr[getDataFlag] = new XSLTProcessor();	
	xslDocArr[getDataFlag] = Sarissa.getDomDocument();
	xslDocArr[getDataFlag].async = true;
	xslDocArr[getDataFlag].onreadystatechange = function (){
		if(xslDocArr[getDataFlag].readyState == 4){
			//alert(Sarissa.serialize(xslDocArr[getDataFlag]));
			if(xslDocArr[getDataFlag].parseError!=0){
				//alert("xsl载入错误！错误描述:\r\n"+Sarissa.getParseErrorText(xslDoc));
				alert("服务器繁忙......");return false;
			}
			processorArr[getDataFlag].importStylesheet(xslDocArr[getDataFlag]);
			processorArr[getDataFlag].setParameter(null, "title", "test");
			xmlDocArr[getDataFlag] = Sarissa.getDomDocument();
			xmlDocArr[getDataFlag].async = true;
			xmlDocArr[getDataFlag].onreadystatechange = function(){
				if(xmlDocArr[getDataFlag].readyState == 4){
					//alert(Sarissa.serialize(xmlDocArr[getDataFlag]));
					if(xmlDocArr[getDataFlag].parseError!=0){
						//alert("xml载入错误！错误描述:\r\n"+Sarissa.getParseErrorText(xmlDoc));
						return false;
					}
					var newDocument = processorArr[getDataFlag].transformToDocument(xmlDocArr[getDataFlag]);
					if(newDocument.parseError!=0){
						var ErrorStr=Sarissa.getParseErrorText(newDocument);
						if(ErrorStr!=Sarissa.PARSED_OK){alert("数据解析错误！错误描述:\r\n"+ErrorStr);Pf_RequestEnd();return false;}
					}
					returnData=Sarissa.serialize(newDocument);
					//alert(returnData);
					if(format){returnData=Sarissa.unescape(returnData);}
					//alert(returnData);
					if(Sid!=null&&Sid!=""){document.getElementById(Sid).innerHTML=returnData;}else{eval(reValue+"=returnData;");eval(func);}
				}
				return;
			};
			xmlDocArr[getDataFlag].load(xmlPath);
			return;
		}
	};
	xslDocArr[getDataFlag].load(xslPath);
	return;
}
//页面失效
function docBlur(){
	var doc = parent.document;
	var object = doc.getElementById('img_bg');
	if(object == null){
		object = doc.createElement('DIV');
		object.id = 'img_bg';
		object.style.position = 'absolute';
		object.style.zIndex = '996';
		object.style.top = 0;
		object.style.left = 0;
		object.style.filter = "Alpha(Opacity=40)";
		doc.body.insertAdjacentElement("afterBegin",object);
		//doc.body.innerHTML += '<div id="img_bg" style="position:absolute;z-index:996;width:0px;height:0px;top:0px;left:0px; background-color:darkgray;Filter: Alpha(Opacity=0);"></div>';
		//object = doc.getElementById('img_bg');
	}
	showDiv("img_wait", true);
	var theTop = (doc.documentElement && doc.documentElement.scrollTop) ? doc.documentElement.scrollTop:doc.body.scrollTop;
	object.style.display = "block";
	object.style.filter = "Alpha(Opacity=40)";
	object.style.backgroundColor = "darkgray";
	object.style.width = doc.body.scrollWidth - 22;
	object.style.height = (doc.body.scrollHeight == 0) ? window.screen.height - 100:doc.body.scrollHeight;
	Opacity = 0;
	//event.srcElement.blur();
	//timer = window.setInterval("showScreen()", 5);
}
//页面有效
function docFocus(){
	showDiv("img_wait", false);
	var object = parent.document.getElementById('img_bg');
 	if(object != null){
		//timer = window.setInterval('hideScreen()', 5);
		object.style.width = 0;
		object.style.height = 0;
		object.style.backgroundColor = "#FFFFFF";
		object.style.filter = "Alpha(Opacity=0)";
		object.style.display='none';
	}
}
//渐变
function showScreen(){
	var doc = parent.document;
	var object = doc.getElementById('img_bg');
	if (Opacity == 30 || object == null){
		window.clearInterval(timer);
		return;
	}
	Opacity = ( Opacity + 5 ) > 30 ? 30 : Opacity + 5;
	object.style.filter = "Alpha(Opacity="  + Opacity + ")";
}
//渐变
function hideScreen(){
	var doc = parent.document;
	var object = doc.getElementById('img_bg');
	if (Opacity == 0 || object == null){
		window.clearInterval(timer);
		return ;
	}
	Opacity = ( Opacity -5 ) < 0 ? 0 : Opacity - 5;
	object.style.filter = "Alpha(Opacity="  + Opacity + ")";
}
function getNodeValue(node, name, value, type){
	var reValue;
	reValue = (type == null) ? node.getAttribute(name):node.getText(name);
	reValue = (reValue == null) ? value:reValue;
	return reValue;
}
//===================数据异步读取结束======================
function getAjaxReturn(url,refun){
	var getDataFlag=getRandFlag();
	if(url.trim() ==''){return false;}
	ajaxArr[getDataFlag] = Sarissa.getDomDocument();
	ajaxArr[getDataFlag].async = true;
	ajaxArr[getDataFlag].onreadystatechange=function(){
		if(ajaxArr[getDataFlag].readyState == 4){		
			if (Sarissa.serialize(ajaxArr[getDataFlag]) != ""){			
				ajax_Con[getDataFlag] = ajaxArr[getDataFlag].selectNodes("/objectSet");		
				if(typeof(refun) =="string" || refun !=null){		
					try{ eval(refun + "ajax_Con[getDataFlag])")} catch(e) {}
				}
			}else{
				//alert('操作无较,请确认你是否登陆\n或者刷新后再试.');
				return false;
			}
		}
	}
	ajaxArr[getDataFlag].load(url);
}
//================异步提交
function subAjaxData(url , refun){
	var getDataFlag=getRandFlag();
	if(url.trim() ==''){return false;}
	ajaxArr[getDataFlag] = Sarissa.getDomDocument();	
	ajaxArr[getDataFlag].async = true;
	ajaxArr[getDataFlag].onreadystatechange=function(){
		if(ajaxArr[getDataFlag].readyState == 4){		
			if (Sarissa.serialize(ajaxArr[getDataFlag]) != ""){					
				ajax_Con[getDataFlag] = ajaxArr[getDataFlag];									
				if(typeof(refun) =="string" || refun !=null){		
					try{ eval(refun + "ajax_Con[getDataFlag])")} catch(e) {}
				}
			}else{
				//alert('操作无较,请确认你是否登陆\n或者刷新后再试.');
				return false;
			}
		}
	}
	ajaxArr[getDataFlag].load(url);
}
//显示dialog页面
function ShowWindowDialog(url, width, height,basePath, object, scorll) {
	var tempstr = "";
	if (width != null && width != "") {width=parseInt(width) + 40;tempstr += "dialogWidth:" + width + "px;";}
	if (height != null && height != "") {height=parseInt(height) + 60;tempstr += "dialogHeight:" + height + "px;"}
	tempstr += (scorll == null || scorll == '') ? "scroll:no;":"scroll:auto;";
	tempstr += "help:no;status:no";
	url = url.escapeUrl();
	//if (object) {object.focus();}	
	var arr = showModalDialog(basePath+"/eshop/info/dialog.jsp?url=" + url + "&h=" + height, window, tempstr);
	//if (object) {object.focus();}
	return arr;
}
//
//取地址栏各参数
function getUrlParam(as_param){
	var fs_url = window.location.href;
	var fi_index,fi_index1;
	fi_index = fs_url.indexOf("?");
	if (fi_index > -1){
		fs_url = "&" + fs_url.substring(fi_index+1);
		fi_index = fs_url.indexOf("&" + as_param + "=");
		if (fi_index > -1){
			fi_index1 = fs_url.indexOf("&",fi_index + 2);
			if (fi_index1 ==-1) fi_index1=9999;
			return fs_url.substring(fi_index + as_param.length + 2,fi_index1);
		}else{
			return "";
		}
	}else{
		return "";
	}
}
function hiddenAllSelect(){
	var allObj = document.getElementsByTagName("select");
	for(var i=0;i<allObj.length;i++){
		allObj[i].style.display = "none";
	}
}
function showAllSelect(){
	var allObj = document.getElementsByTagName("select");
	for(var i=0;i<allObj.length;i++){
		allObj[i].style.display = "";
	}
}
//inteface of eshop's info
function infoDetail(infoId,eshopId){
	window.open("eshopShow.do?act=getInfo&infoId="+infoId+"&eshopId="+eshopId);
}
//calculate simmessge 's length
function calcText(content){
	var obj;
	if(typeof(content)=='string'){
		obj=document.getElementById(content);
		}else{
			obj = content;
			}
	var txt = obj.innerHTML;		
	var len = txt.trim().length;
	var num = (len / 50);	
	document.getElementById("textLen").innerHTML =parseInt(len);
	document.getElementById("textNum").innerHTML=parseInt(num)+1;
}